<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>北京市昌平振华学校</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
        <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
        <script type="text/javascript">
            $(function () {
                $(".amt").mouseout(function () {
                    totalComputer();
                });
                $("#feeId").blur(function () {
                    totalComputer();
                });
                $("#doprintId").click(function () {
                    $("#psname").text($("#snameId").val());
                    $("#pphone").text($("#phoneId").val());
                    $("#pclass").text($("#yearId").val()+$("#classId").val());

                    $("#pfee").text($("#feeId").val());

                    $("#pzq").text($("#zyearId").val()+$("#ztermId").val());

                    $("#pzc").text(getCheckBox($("#zcId")));
                    $("#pwc").text(getCheckBox($("#wcId")));
                    $("#pwac").text(getCheckBox($("#wacId")));
                    $("#pbc").text(getCheckBox($("#bcId")));
                    $("#pbx").text(getCheckBox($("#bxId")));
                    $("#pxf").text(getCheckBox($("#xfId")));
                    $("#pzs").text(getCheckBox($("#zsId")));

                    $("#psfr").text($("#sfyId").val());
                    $("#totalId").text($("#totalAmt").val());

                    var htmlstr = $("#printAearId").html();
                    window.document.body.innerHTML=htmlstr
                    window.print();
                    window.location.reload();
                });
                // 获取值
                function getCheckBox(obj) {
                    if(obj.is(':checked'))
                        return $("#wcId").val();
                    return 0
                }

                // 账单计算
                function totalComputer() {

                    var feeAmt = 0;
                    if (!isNaN($("#feeId").val())) {
                        feeAmt = parseFloat($("#feeId").val());
                    }
                    var zcAmt = 0;
                    if (!isNaN($("#zcId").val()) && $("#zcId").is(':checked')) {
                        zcAmt = parseFloat($("#zcId").val());
                    }
                    var wcAmt = 0;
                    if (!isNaN($("#wcId").val()) && $("#wcId").is(':checked')) {
                        wcAmt = parseFloat($("#wcId").val());
                    }
                    var wacAmt = 0
                    if (!isNaN($("#wacId").val()) && $("#wacId").is(':checked')) {
                        wacAmt = parseFloat($("#wacId").val());
                    }
                    var bcAmt = 0;
                    if (!isNaN($("#bcId").val()) && $("#bcId").is(':checked')) {
                        bcAmt = parseFloat($("#bcId").val());
                    }
                    var zsAmt = 0;
                    if (!isNaN($("#zsId").val()) && $("#zsId").is(':checked')) {
                        zsAmt = parseFloat($("#zsId").val());
                    }
                    var xfAmt = 0;
                    if (!isNaN($("#xfId").val()) && $("#xfId").is(':checked')) {
                        xfAmt = parseFloat($("#xfId").val());
                    }
                    var bxAmt = 0;
                    if (!isNaN($("#bxId").val()) && $("#bxId").is(':checked')) {
                        bxAmt = parseFloat($("#bxId").val());
                    }
                    totalAmt = feeAmt + zcAmt + wcAmt + wacAmt + bcAmt + zsAmt + xfAmt + bxAmt;
                    if (isNaN(totalAmt)) {
                        totalAmt = 0;
                    } else {
                        $("#totalAmt").val(totalAmt);
                    }

                }
            });
        </script>
</head>
<body>
<div class="container">
	<div class="row clearfix">
		<div class="col-md-12 column">
			<ul class="nav nav-pills">
				<li class="active">
					 <a href="${pageContext.request.contextPath}/bill/allBill">收银管理</a>
				</li>
				<li>
					 <a href="${pageContext.request.contextPath}/clazz/allClass">班级管理</a>
				</li>
				<li >
					 <a href="${pageContext.request.contextPath}/student/allStudent">学生管理</a>
				</li>
			</ul>
			<div class="row clearfix">
				<div class="col-md-12 column">
				</div>
			</div>
		</div>
	</div>
</div>
 <form action="${pageContext.request.contextPath}/bill/addBill" method="post">
  <span id="studentInfo">
    <hr width="30%"/>
    <table cellpadding="1" cellspacing="1" align="center" width="30%" bgcolor="#dcdcdc">
        <tr style="background-color: gainsboro;">
            <td colspan="2" style="text-align: center;font-style: initial;">学生信息</td>
        </tr>
        <tr>
            <th>学生姓名：</th>
            <td><input type="text" class="amt" name="sName" id="snameId" value=""/></td>
        </tr>
        <tr>
            <th>联系方式：</th>
            <td><input type="text" class="amt" name="MonitorPhone" id="phoneId" value=""/></td>
        </tr>
        <tr>
            <th>年级班级：</th>
            <td><select id="yearId" name="yearName">
                <option value="幼小衔接">幼小衔接</option>
                <option value="一年级">一年级</option>
                <option value="二年级">二年级</option>
                <option value="三年级">三年级</option>
                <option value="四年级">四年级</option>
                <option value="五年级">五年级</option>
                <option value="六年级">六年级</option>
                <option value="七年级">七年级</option>
                <option value="八年级">八年级</option>
                <option value="九年级">九年级</option>
            </select>
                <select id="classId" name="className">
                    <option value="一班">一班</option>
                    <option value="二班">二班</option>
                    <option value="三班">三班</option>
                    <option value="四班">四班</option>
                    <option value="五班">五班</option>
                    <option value="六班">六班</option>
                </select>
            </td>
        </tr>
    </table>
    <hr width="30%"/>
  </span>
    <table cellspacing="1" cellpadding="1" align="center" width="30%">
        <tr style="background-color: gainsboro;">
            <th colspan="2" style="text-align: center;font-style: initial;">缴费项目</th>
        </tr>
        <tr>
            <th align="left">学年：<select id="zyearId" name="billYear">
                <option value="2021年">2021年</option>
                <option value="2022年">2022年</option>
                <option value="2023年">2023年</option>
                <option value="2024年">2024年</option>
                <option value="2025年">2025年</option>
            </select></th>
            <th align="left">学期：<select id="ztermId" name="billTerm">
                <option value="上学期">上学期</option>
                <option value="下学期">下学期</option>
            </select></th>
        </tr>
        <tr>
            <th align="left">学&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;费：</th>
            <td align="left"><input type="text" value="0" name="fee" id="feeId"/></td>
        </tr>

        <tr>
            <th align="left">其&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;它：</th>
            <td align="left" style="text-align: left;">

                <input type="checkbox" name="bcAmt" class="amt" id="bcId" value="1"/> 班车
                <input type="checkbox" name="bxAmt" class="amt" id="bxId" value="1"/> 保险
                <input type="checkbox" name="bcAmt" class="amt" id="xfId" value="1"/> 校服
                <input type="checkbox" name="zsAmt" class="amt" id="zsId" value="1"/> 住宿
            </td>
        </tr>
        <tr>
            <th align="left">餐&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;费：</th>
            <td align="left">
                <input type="checkbox" name="zcAmt" class="amt" id="zcId" value="1"/> 早餐
                <input type="checkbox" name="wcAmt" class="amt" id="wcId" value="1"/> 午餐
                <input type="checkbox" name="wacAmt" class="amt" id="wacId" value="1"/> 晚餐
            </td>
        </tr>
        <tr>
            <td align="left">总&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;计：</td>
            <td align="left"><input name="totalAmt" id="totalAmt" value="0" disabled/></td>
        </tr>
    </table>
    <table cellspacing="1" cellpadding="1" align="center" width="30%">
        <tr>
            <th align="left">收费人：</th>
            <th align="left"><select id="sfyId" name="billOp">
                <option value="万世钰">万世钰</option>
                <option value="万俊杰">万俊杰</option>
            </select></th>
        </tr>
    </table>
    <table cellspacing="1" cellpadding="1" align="center" width="30%">
        <tr>
            <td><input type="button" name="doprint" id="doprintId" value="打印账单"></td> <td><input type="submit" value="缴费入账"/></td>
        </tr>
    </table>
    </form>


<div id="printAearId" style="width: 30%;align-content: center;margin-left: 450px;display: none;">
    <hr style="border:1px dotted #036" />
    <table cellspacing="1" cellpadding="1" width="100%">
        <tr><th colspan="2">学生基本信息</th></tr>
        <tr><th>学生姓名：</th><td><span id="psname"></span></td></tr>
        <tr><th>学生班级：</th><td><span id="pclass"></span></td></tr>
        <tr><th>联系方式：</th><td><span id="pphone"></span></td></tr>
        <tr><td colspan="2"><hr style="border:1px dotted #036" /></td></tr>
        <tr><th colspan="2">缴费项目</th></tr>
        <tr><th>账期：</th><td><span id="pzq"></span></td></tr>
        <tr><th>学费：</th><td><span id="pfee">0</span></td></tr>
        <tr><th>早餐：</th><td><span id="pzc">0</span></td></tr>
        <tr><th>午餐：</th><td><span id="pwc">0</span></td></tr>
        <tr><th>晚餐：</th><td><span id="pwac">0</span></td></tr>
        <tr><th>校服：</th><td><span id="pxf">0</span></td></tr>
        <tr><th>保险：</th><td><span id="pbx">0</span></td></tr>
        <tr><th>班车：</th><td><span id="pbc">0</span></td></tr>
        <tr><th>住宿：</th><td><span id="pzs">0</span></td></tr>
        <tr><td colspan="2"><hr style="border:1px dotted #036" /></td></tr>
        <tr><th>小计：</th><td><span id="totalId"></span></td></tr>
        <tr><th>收费人：</th><td><span id="psfr"></span></td></tr>
    </table>
</div>
</body>